package com.redstar.HappyRefresh.pojo;

import com.redstar.HappyRefresh.cache.UserInfo;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
public class UserModel {
    private List<Model> models;
    private Long userId;

    public static UserModel buildUserModel(List<String> labels, Long videoId, Double score) {
        // 记录修改用户模型的数据
        UserModel userModel = new UserModel();
        ArrayList<Model> models = new ArrayList<>();
        userModel.setUserId(UserInfo.get());
        for (String label : labels) { // 将一个视频的多个标签封装成模型
            Model model = new Model();
            model.setLabels(label); // 视频标签
            model.setScore(score); // 视频的推送概率
            model.setId(videoId); // 视频Id
            models.add(model);
        }
        userModel.setModels(models);
        return userModel;
    }
}
